<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class BlogArticles extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title',200)->index('title')->comment('标题');
            $table->string('flag',100)->index('flag')->default("")->comment('标记');
            $table->string('keywords')->nullable($value = true)->default("")->comment('关键字');
            $table->string('description')->nullable($value = true)->default("")->comment('描述');
            $table->string('picname')->nullable($value = true)->default("")->comment('缩略图');
            $table->unsignedTinyInteger('type')->default(1)->comment('正文类型');
            $table->text('body')->comment('内容');
            $table->integer('click')->unsigned()->default(0)->comment('浏览量');
            $table->integer('praise')->unsigned()->default(0)->comment('点赞量');
            $table->integer('user_id')->unsigned()->comment('用户ID');
            $table->integer('type_id')->index('type_id')->unsigned()->comment('栏目ID');
            $table->integer('case_id')->index('case_id')->default(0)->nullable(true)->unsigned()->comment('专栏ID');
            $table->integer('addtime')->unsigned()->comment('添加时间');
            $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('articles');
    }
}
